class PostsController < ApplicationController
before_action :log_in_user,only: [:create,:destroy]
before_action :correct_user,only: :destroy

def new
end

def create


		@post=current_user.posts.build(post_params)
		if @post.save
			flash[:success]='微博创建成功'
			redirect_to root_url
		else
			flash.now[:warning]='创建失败'
			render 'staticpages/index'

		end

	end

	# def edit
	#
	#
	# end

	# def update
	# 	update_attribute(:content,params[:content])
	#
	# end

	def destroy
		Post.find(params[:id]).destroy
		redirect_to root_url
	end

	private

		def post_params
			params.require(:post).permit(:content)

		end


end
